package com.message;

import com.message.client.MessageClient;
import com.message.configuration.MessageConfiguration;
import lombok.Data;

import java.util.List;
@Data
public class MessageSenderTemplate {

    private MessageConfiguration messageConfiguration;

    private List<List<? extends MessageClient>> messageClientList;
    /**
     * 获取存储客户端
     * @param client
     * @return
     */
    public MessageClient getMessageClient(String client) {
        for (List<? extends MessageClient> messageClients : messageClientList) {
            for (MessageClient messageClient : messageClients) {
                if (messageClient.getClient().equals(client)) {
                    return messageClient;
                }
            }
        }
        return null;
    }

    /**
     * 获取默认存储客户端
     * @return
     */
    public MessageClient getDefaultStorageClient() {
        return getMessageClient(messageConfiguration.getDefaultClient());
    }
}
